From: Keir Fraser Date: Thu, 20 Sep 2007 14:59:51 +0000 (+0100) Subject: vtd: Fix init/destroy domain hooks. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14937^2~51 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b35124143b08de32a5fb5a8a988b0f4e4711a092;p=xen.git vtd: Fix init/destroy domain hooks. Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 2080e70961..dafee075f9 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef CONFIG_COMPAT #include #endif @@ -505,10 +506,16 @@ int arch_domain_create(struct domain *d) virt_to_page(d->shared_info), d, XENSHARE_writable); } + if ( (rc = iommu_domain_init(d)) != 0 ) + goto fail; + if ( is_hvm_domain(d) ) { if ( (rc = hvm_domain_initialise(d)) != 0 ) + { + iommu_domain_destroy(d); goto fail; + } } else { @@ -538,6 +545,8 @@ void arch_domain_destroy(struct domain *d) if ( is_hvm_domain(d) ) hvm_domain_destroy(d); + iommu_domain_destroy(d); + paging_final_teardown(d); free_xenheap_pages( diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index da0bc8fcdc..b465a03b80 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -48,7 +48,6 @@ #include #include #include -#include int hvm_enabled __read_mostly; @@ -220,21 +219,13 @@ int hvm_domain_initialise(struct domain *d) if ( rc != 0 ) return rc; - rc = iommu_domain_init(d); - if ( rc != 0 ) - return rc; - vpic_init(d); vioapic_init(d); hvm_init_ioreq_page(d, &d->arch.hvm_domain.ioreq); hvm_init_ioreq_page(d, &d->arch.hvm_domain.buf_ioreq); - rc = hvm_funcs.domain_initialise(d); - if ( rc != 0 ) - release_devices(d); - - return rc; + return hvm_funcs.domain_initialise(d); } void hvm_domain_relinquish_resources(struct domain *d) @@ -250,7 +241,6 @@ void hvm_domain_relinquish_resources(struct domain *d) void hvm_domain_destroy(struct domain *d) { - release_devices(d); hvm_funcs.domain_destroy(d); } diff --git a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c index 927c68064b..f1f77fcb08 100644 --- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c +++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c @@ -972,7 +972,7 @@ int iommu_domain_init(struct domain *domain) gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: hardware doesn't support the agaw\n"); agaw = find_next_bit(&sagaw, 5, agaw); - if (agaw >= 5) + if ( agaw >= 5 ) return -ENODEV; } hd->agaw = agaw; diff --git a/xen/arch/x86/hvm/vmx/vtd/io.c b/xen/arch/x86/hvm/vmx/vtd/io.c index 48b0813688..89f0a90363 100644 --- a/xen/arch/x86/hvm/vmx/vtd/io.c +++ b/xen/arch/x86/hvm/vmx/vtd/io.c @@ -134,19 +134,17 @@ void hvm_dpci_eoi(unsigned int guest_gsi, union vioapic_redir_entry *ent) } } -int release_devices(struct domain *d) +void iommu_domain_destroy(struct domain *d) { struct hvm_domain *hd = &d->arch.hvm_domain; uint32_t i; - int ret = 0; if ( !vtd_enabled ) - return ret; + return; for ( i = 0; i < NR_IRQS; i++ ) if ( hd->irq.mirq[i].valid ) - ret = pirq_guest_unbind(d, i); + pirq_guest_unbind(d, i); iommu_domain_teardown(d); - return ret; } diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h index cc19d840fd..914145c503 100644 --- a/xen/include/asm-x86/iommu.h +++ b/xen/include/asm-x86/iommu.h @@ -68,8 +68,8 @@ struct iommu { int iommu_setup(void); int iommu_domain_init(struct domain *d); +void iommu_domain_destroy(struct domain *d); int assign_device(struct domain *d, u8 bus, u8 devfn); -int release_devices(struct domain *d); int iommu_map_page(struct domain *d, dma_addr_t gfn, dma_addr_t mfn); int iommu_unmap_page(struct domain *d, dma_addr_t gfn); void iommu_flush(struct domain *d, dma_addr_t gfn, u64 *p2m_entry);